package com.raven.craft.code.generator.common.file.metadata;

import com.raven.craft.code.generator.common.constant.FileSuffix;
import com.raven.craft.code.generator.common.util.PathUtil;
import org.springframework.util.StringUtils;

/**
 * @author raven
 * @date 2020/09/16
 **/
public class JavaFileMetadata extends FileMetadata {

    public JavaFileMetadata(String name, String path, String targetPackage) {
        super(name, FileSuffix.JAVA, getJavaFilePath(path, targetPackage));
    }

    private static String getJavaFilePath(String path, String targetPackage) {
        String _path = PathUtil.getPathWithScratch(path);
        return StringUtils.isEmpty(targetPackage) ? _path : _path + targetPackage.replaceAll("\\.", "/");
    }

}
